<?php 
require_once ("../../../../init.php");
$pageSize=15;
$company_name   = !empty($_REQUEST['query'])&&($_REQUEST['query']!="?")&&($_REQUEST['query']!="？") ? trim($_REQUEST['query']) : "";
$condition=array();
if (!empty($company_name)){
    $condition["company_name"]=" like '%$company_name%'";
}
$start=0;
if (isset($_REQUEST['start'])){
    $start=$_REQUEST['start']+1;
}
$limit=$pageSize;
if (isset($_REQUEST['limit'])){
    $limit=$_REQUEST['limit'];
    $limit= $start+$limit-1;
}

if (HttpSession::get('roletype') != 0) {
  $company_id = HttpSession::get('company_id');
  if ($company_id){
      $condition["company_id"] = $company_id;
  }
}

$arr['totalCount']= Company::count($condition);
$arr['companys']    = Company::queryPage($start,$limit,$condition);
echo json_encode($arr);
?>
